package com.me.info;

import java.util.ArrayList;

import com.badlogic.gdx.scenes.scene2d.Group;
import com.me.constant.Constant;

public class PlayBoardInfo extends Group{

	int row;
	int col;
	int width;
	public static int iClick = 0;
	public static int firstPos;
	public static int secondPos;
	public static int iCountEqual = 0;
	
	public static ArrayList<MyImage> listImage = new ArrayList<MyImage>();
	
	@SuppressWarnings("static-access")
	public PlayBoardInfo(ArrayList<MyImage> listImg, int row, int col, int width){
		this.listImage = listImg;
		this.row = row;
		this.col = col;
		this.width = width;
		
		float posX = 0;
		float posY = 0;
		float posYTemp = (Constant.STAGE_HEIGHT - Constant.wh_Image*Constant.row)/2;
		float posXTemp = (Constant.STAGE_WIDTH - Constant.wh_Image*Constant.col)/2;
		
		for(int i = 0; i < listImg.size(); i++) {
			if((i%col * width) != 0)
				posX = i % col * width + posXTemp;
			else
				posX = posXTemp;
			if((i / col * width) != 0)
				posY = i / col * width + posYTemp;
			else
				posY = posYTemp;
			listImg.get(i).getImg().setX(posX);
			listImg.get(i).getImg().setY(posY);
			
			this.addActor(listImg.get(i).getImg());
		}
		
	}
	
	public static boolean check() {
		if(firstPos == secondPos)
			return false;
		if (listImage.get(firstPos).iValueSelected == listImage.get(secondPos).iValueSelected) {
			return true;
		}
		return false;
	}
	
	public static void reset() {
		listImage.get(firstPos).reset();
		listImage.get(secondPos).reset();
	}
}
